<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys"%>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>${tabTitle}</title>
    <jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
            <form id="no_sign_time_info_add">
                <div class="fieldset1 tabel_col clearFix">
                    <div class="fieldBox col_100" id="searchPrjStsCdId">
                        <div class="label">机构名称</div>
                        <div class="field">
                            <select name="insId"  id="insId" validate="{required:true}">
                                <option value="" selected="selected">--请选择--</option>
                                <c:forEach items="${insList}" var="opt">
                                    <option value="${opt.insId}">${opt.insName}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="fieldBox col_66_auto" >
                        <div class="label">不可签署时间</div>
                        <div class="field">
                            <input name="startTm" id="startTm" type="text" class="ui-datepicker" value="" validate="{required:true}">-
                            <input name="endTm" id="endTm" type="text" class="ui-datepicker" value="" validate="{required:true}">
                        </div>
                    </div>
                </div>
                <div class="btnsBox" style="text-align: center;">
                    <span id="saveBtn"  class="sq-button sq-button-round">保存</span>
                    <span id="cancelBtn" class="sq-button sq-button-round">取消</span>
                </div>
                <div class="btnsBox" style="height: 100px"></div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">

    $(function(){
        $("#startTm").ligerDateEditor({
            showTime: true,
            width: "180",
            format: "hh:mm"

        });
        $("#endTm").ligerDateEditor({
            showTime: true,
            width: "180",
            format: "hh:mm"

        });

        var no_sign_time_info_add = $('#no_sign_time_info_add').ligerForm({
            validate : true
        });
        SET_popupIframeHeight();


        //关闭
        $('#cancelBtn').click(function(){
            frameElement.dialog.close();
        });

        //保存
        $('#saveBtn').click(function () {
            var options = $("#insId option:selected");　　　　//获取选中项
            var insId = options.val();
            var startTm = new Date().Format($("#startTm").val());
            var endTm = new Date().Format($("#endTm").val());
            var a = new Date(startTm).getHours();
            var b = new Date(endTm).getHours();
            if (null ==insId || ''==insId ){
                UIUtils.alertError("请选择机构");
                return;
            }
            if (null ==startTm || ''==startTm ){
                UIUtils.alertError("请选择开始时间");
                return;
            }
            if (null ==endTm || ''==endTm ){
                UIUtils.alertError("请选择结束时间");
                return;
            }
            if (endTm < startTm){
                var start = Date.parse("9999-12-31 "+startTm+":00");
                var end = Date.parse("9999-12-31 "+endTm+":00");
                if (start>end){
                    UIUtils.alertError("开始时间不能大于结束时间");
                    return;
                }
            }
            $.ajax({
                url: "<%=path%>/institution/nosigndate/updatenosigndate.do",
                data: JSON.stringify({
                    insId: insId,
                    startTime:"9999-12-31 "+startTm+":00",
                    endTime:"9999-12-31 "+endTm+":00",
                    insertFlag:true
                }),
                contentType:"application/json; charset=utf-8",
                dataType: "json",
                type: "post",
                async: false,
                cache: false,
                success: function (msg) {
                    if (msg.success == 1) {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        parent.$("#searchBtn").click();
                        frameElement.dialog.close();
                    } else {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                    grid.reload()
                },
                error: function () {
                    UIUtils.alertError("保存失败");
                }
            });

        })
    })
</script>

</body>
</html>